package com.itheima.reggie.mapper;

import com.itheima.reggie.entity.Dish;
import com.itheima.reggie.entity.dto.DishDto;
import org.apache.ibatis.annotations.*;

import java.util.List;

public interface DishMapper {

    //根据id查询菜品类
    @Select("select count(*) from dish where category_id=#{id}")
    int findCountByCategoryId(Long id);

    //添加菜品
    @Insert("insert into  dish values(null,#{name},#{categoryId},#{price},#{code},#{image},#{description},#{status},#{sort},#{createTime},#{updateTime},#{createUser},#{updateUser},0)")
    @Options(useGeneratedKeys = true,keyProperty = "id",keyColumn = "id")
    void save(DishDto dishDto);

    //根据名字查询菜品列表
    List<Dish> findByName(String name);

    //根据id查询菜品信息
    @Select("select * from dish where id=#{id}")
    Dish findById(Long dishId);

    //根据id修改菜品信息
    void updateById(DishDto dishDto);

    //根据类别查询菜品
    @Select("select * from dish where category_id=#{categoryId} and status=#{status}")
    List<Dish> fingByCategoryId(@Param("categoryId") Long categoryId ,@Param("status") Integer status);

    //根据状态查找菜品
    long findDishByStatus(@Param("ids") List<Long> ids);

    //根据id删除菜品
    void deleteByIds(List<Long> ids);

    //
    void updateStatusById(@Param("ids") List<Long> ids ,@Param("status") Integer status);
}
